package com.leo;

import javafx.application.Application;
import javafx.application.Platform;
import javafx.geometry.Rectangle2D;
import javafx.stage.Screen;
import javafx.stage.Stage;

/**
 * @ClassName ScreenTools
 * @Description 获取电脑的屏幕信息工具类
 * @Author wangss
 * @date 2020.05.16 00:41
 * @Version 1.0
 */
public class ScreenTools extends Application {

    public static void main(String[] args) {
        launch(args);
    }

    @Override
    public void start(Stage primaryStage) throws Exception {
        // 获取主屏幕
        Screen screen = Screen.getPrimary();

        double screenDpi = screen.getDpi();

        // 获取屏幕的全部范围
        Rectangle2D bounds = screen.getBounds();

        // 获取屏幕可视范围
        Rectangle2D visualBounds = screen.getVisualBounds();

        System.out.println("当前屏幕dpi = " + screenDpi);

        System.out.println("屏幕全部范围");
        System.out.println("左上角x = " + bounds.getMinX() + "  " + "左上角y = " + bounds.getMinY());
        System.out.println("右下角x = " + bounds.getMaxX() + "  " + "右下角y = " + bounds.getMaxY());
        System.out.println("宽度 = " + bounds.getWidth() + "  " + "高度 = " + bounds.getHeight());

        System.out.println("屏幕可视范围");
        System.out.println("左上角x = " + visualBounds.getMinX() + "  " + "左上角y = " + visualBounds.getMinY());
        System.out.println("右下角x = " + visualBounds.getMaxX() + "  " + "右下角y = " + visualBounds.getMaxY());
        System.out.println("宽度 = " + visualBounds.getWidth() + "  " + "高度 = " + visualBounds.getHeight());


        Platform.exit();
    }
}
